package com.shkco.xbjcc.controller;

import com.shkco.result.JSONResult;
import com.shkco.xbjcc.doc.CourseDoc;
import com.shkco.xbjcc.dto.CourseEsDto;
import com.shkco.xbjcc.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course")
public class SearchController {

    @Autowired
    private ISearchService searchService;

    @RequestMapping(value="/saveSearch",method= RequestMethod.POST)
    public JSONResult saveSearch(@RequestBody CourseDoc courseDoc){
        searchService.saveSearch(courseDoc);
        return JSONResult.success();
    }

    @RequestMapping(value="/delSearch/{id}",method= RequestMethod.POST)
    public JSONResult delSearch(@PathVariable("id") Long id){
        searchService.delSearch(id);
        return JSONResult.success();
    }


    @RequestMapping(value="/search",method= RequestMethod.POST)
    public JSONResult search(@RequestBody CourseEsDto courseEsDto){
        return JSONResult.success(searchService.search(courseEsDto));
    }
}
